package common;

public class HistoWord implements Comparable {
  public String text;
  public Integer count;
  
  public HistoWord(String wordText, Integer count) {
    this.text = wordText;
    this.count = count;
  }
  
  public int compareTo(Object obj) {
    if(obj instanceof HistoWord) {
      return compareTo((HistoWord)obj);
    }
    else
      throw new ClassCastException("Cannot compare "+obj.getClass().getName() + " to a HistoWord");
  }
  
  public int compareTo(HistoWord word) {
    int equality = this.count.compareTo(word.count);
    if(equality == 0)
      equality = this.text.compareTo(word.text);
    return equality;
  }
}
